// utils/formatTime.js
const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}

// 时间格式化过滤器
const timeFormat = time => {
  const timeMap = {
    'breakfast': '早餐',
    'lunch': '午餐',
    'dinner': '晚餐'
  }
  return timeMap[time] || time
}

// 获取星期几
const getWeekDay = date => {
  const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  return weekDays[new Date(date).getDay()]
}

module.exports = {
  formatTime,
  timeFormat,
  getWeekDay
}